package org.example.tcp.server;

import org.example.common.MyConverter;
import org.example.tcp.TcpData;

import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;
import java.net.SocketException;

public class clientRunable implements Runnable{
    private Socket socket = null;
    public clientRunable(Socket socket){
        this.socket = socket;
    }
    @Override
    public void run() {
        while(true){
            try {
                InputStream inputStream = socket.getInputStream();
                byte[] bytes = new byte[1024];
                int len = inputStream.read(bytes);
                String message = new String(bytes, 0, len);
                System.out.println(message);
            } catch (SocketException e) {
                System.out.println("服务器断开连接！！");
                break;
            }catch (Exception e){
                e.printStackTrace();
                break;
            }
        }
    }
}
